package me.kuye.jkuye.log;

import java.util.logging.Level;

public class DefaultLogger extends Logger{

	private java.util.logging.Logger log;
	private String name;
	
	DefaultLogger(Class<?> clazz) {
		log = java.util.logging.Logger.getLogger(clazz.getName());
		this.name = clazz.getName();
	}
	
	DefaultLogger(String name) {
		log = java.util.logging.Logger.getLogger(name);
		this.name = name;
	}
	
	public void debug(String message) {
		log.logp(Level.FINE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message);
	}
	
	public void debug(String message,  Throwable t) {
		log.logp(Level.FINE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message, t);
	}
	
	public void info(String message) {
		log.logp(Level.INFO, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message);
	}
	
	public void info(String message, Throwable t) {
		log.logp(Level.INFO, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message, t);
	}
	
	public void warn(String message) {
		log.logp(Level.WARNING, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message);
	}
	
	public void warn(String message, Throwable t) {
		log.logp(Level.WARNING, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message, t);
	}
	
	public void error(String message) {
		log.logp(Level.SEVERE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message);
	}
	
	public void error(String message, Throwable t) {
		log.logp(Level.SEVERE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message, t);
	}
	
	public void fatal(String message) {
		log.logp(Level.SEVERE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message);
	}
	public void fatal(String message, Throwable t) {
		log.logp(Level.SEVERE, name, Thread.currentThread().getStackTrace()[1].getMethodName(), message, t);
	}
	
	public boolean isDebugEnabled() {
		return log.isLoggable(Level.FINE);
	}
	
	public boolean isInfoEnabled() {
		return log.isLoggable(Level.INFO);
	}
	
	public boolean isWarnEnabled() {
		return log.isLoggable(Level.WARNING);
	}
	
	public boolean isErrorEnabled() {
		return log.isLoggable(Level.SEVERE);
	}
	
	public boolean isFatalEnabled() {
		return log.isLoggable(Level.SEVERE);
	}
}
